﻿using System;
using System.IO;

namespace InnovTech.Util
{
    public static class Ensure
    {

        public static void IsNotNull(object toEnsure)
        {
            if (toEnsure == null)
                throw new ArgumentNullException("The given object is null");
        }

        public static void IsStringNotEmpty(string toEnsure)
        {
            if (String.Empty.Equals(toEnsure))
                throw new ArgumentException("The given string is null");
        }

        public static void FileExists(string filePath)
        {
            IsNotNull(filePath);
            IsStringNotEmpty(filePath);
            if (!File.Exists(filePath))
                throw new FileNotFoundException("The gien file path does not exist");
        }

        public static void DirectoryExists(string dir)
        {
            IsNotNull(dir);
            IsStringNotEmpty(dir);
            if (!Directory.Exists(dir))
                throw new DirectoryNotFoundException("The gien directory does not exist");
        }
    }
}
